package com.senac.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.text.MessageFormat;

public class ConnectionFactory {

	private static final String USERNAME = "root";
	private static final String PASSWORD = "12345";
	private static final String PORT = "3306";
	private static final String DATABASE = "gerenciamento_escola";
	private static final String URL = "jdbc:mysql://localhost:{0}/{1}";
	
	static {
		configureConnection();
	}
	

	public static Connection getConnection() {
		Connection con = null;
		try {
			con = DriverManager.getConnection(MessageFormat.format(URL, PORT, DATABASE), USERNAME, PASSWORD);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return con;
	}
	
	private static void configureConnection() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
}
